<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<html>
<head th:include="common/common::header">
<meta charset="UTF-8">
<style type="text/css">
#index {
	padding: 15px;
	display: flex;
	justify-content: space-between;
	flex-wrap: wrap;
	opacity: 0;
	font-size: 12px;
}

.index-l {
	padding: 10px;
	width: 48%;
	overflow: auto;
}
</style>
</head>

<body>
	<div id="index">
		<form id="sysRoleDtos_form" class="easyui-form" method="post" data-options="novalidate:true">
		<div class="contentWrapper">
			<!--tab-->
			<div class="index-l">
				<div id="tt" class="easyui-tabs" data-options="tabHeight:31"
					style="width: 100%;">
					<div title="基础配置" style="padding: 20px; display: none;">
						<div class="contentWrapper">
							<div style="opacity: 1;width:66%; float:left ">
							<input type="hidden" id="sysRole_id" name="id" th:value="${sysRoleDto.id }">
							<input type="hidden" id="sysRole_orgid" name="orgid" th:value="${sysRoleDto.orgid }">
							<input type="hidden" id="sysRoleDto_resourceIds" name="resourceIds" th:value="${sysRoleDto.resourceIds }">
							<div class="form-item">
								<label for="" class="label-top">角色名称：</label> <input
									id="sysRole_name" name="name" class="easyui-validatebox easyui-textbox"
									data-options="required:true" style="width: 90%;"
									th:value="${sysRoleDto.name }">

							</div>
							<br>
							<div class="form-item">
								<label for="" class="label-top">角色排序：</label> <input id="sysRole_sort"
									class="easyui-validatebox easyui-numberbox" name="sort"
									data-options="required:true" style="width: 90%;"
									th:value="${sysRoleDto.sort }">

							</div>
							<br>
								<div class="form-item">
									<label for="" class="label-top">是否可用：</label> <input
										id="sysRole_enable" class="easyui-combobox"
										data-options="textField:'text',valueField:'id',editable:false,panelHeight:null,url:'/system/common/load_enabled.do'" name="enabled"
										style="width: 90%;" th:value="${sysRoleDto.enabled }">
								</div>
							<br>
							<div class="form-item">
								<label for="" class="label-top">角色描述：</label> <input id="sysRole_description"
									class="easyui-validatebox easyui-textbox" name="description"
									data-options="required:false" style="width: 90%;" th:value="${sysRoleDto.description }">

							</div>
							</div>
							<div style = "right:20px;height:300px; top:20px;float:left" class="easyui-panel" data-options="border:false,doSize:false">
							<div class="form-item">
		                        <label for="" class="label-top">拥有资源：</label>
		                         <ul id="resourceTree" style="width: 90%;" class="easyui-tree"  th:attr="data-options='parentField:\'pid\',textFiled:\'text\',idFiled:\'id\',animate:true,url:\'/system/role/load_resource.do?id='+${sysRoleDto.id}+'\',checkbox:true'"></ul>  	
                   			 <div>
                   			 </div>
						</div>
					</div>
					</div>
				</div>
			</div>
					<div style="margin-top: 1%; padding-left: 37.5%">
						<a href="javascript:void(0)" onclick="submitForm()" class="easyui-linkbutton"data-options="iconCls:'fa fa-floppy-o'"style="height: 30px; border-left-width: 1px;">保存</a> 
						<a id="sysRoleDtos_close" onclick="closedialog(this)"href="javascript:void(0)" class="easyui-linkbutton"data-options="iconCls:'fa fa-ban'"style="height: 30px; border-left-width: 1px;">取消</a>
					</div>
		</form>
	</div>
	
<script type="text/javascript">


function submitForm(){
	var nodes = jQuery('#resourceTree').tree('getChecked', [ 'checked', 'indeterminate' ]);
	var myArray = new Array();
	for (var i = 0; i < nodes.length; i++) {
		var resourcesJson = new Object();
		resourcesJson.checked = nodes[i].checked?'1':'0';
		resourcesJson.resourcesIds = nodes[i].id;
		myArray.push(resourcesJson);
	}
	jQuery("#sysRoleDto_resourceIds").val(JSON.stringify(myArray));
	$('#sysRoleDtos_form').form('submit',{
		url:'/system/role/save.do',
		onSubmit:function(){
			return $(this).form('enableValidation').form('validate');
		},
		 success: function (data) {
			 if (JSON.parse(data).status ==200) {
				 	break_save();
				} else {
						$.messager.alert('消息',JSON.parse(data).msg);
				}
		 }
	});
}


</script>
</body>
</html>